<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<link rel="stylesheet" type="text/css" href="${contextPath}/admin/stylesheets/common.css?v=${sversion}" media="screen" />
	<link rel="stylesheet" type="text/css" href="${contextPath}/admin/stylesheets/table.css?v=${sversion}" media="screen" />
	<script type="text/javascript" src="${contextPath}/ext/jquery/jquery-1.8.1.min.js"></script>
	<script type="text/javascript" src="${contextPath}/ext/jquery_form/jquery.form.min.js"></script>
	<script type="text/javascript" src="${contextPath}/ext/layer/layer.min.js"></script>
	<script type="text/javascript" src="${contextPath}/ext/laydate/laydate.js"></script>
	
	
	<script type="text/javascript" src="${contextPath}/admin/ext/jquery/selectbox.js"></script>
	<script type="text/javascript" src="${contextPath}/admin/ext/zw/check.js?v=${sversion}"></script>
	<script type="text/javascript" src="${contextPath}/admin/javascripts/zcommon.js?v=${sversion}" basepath="${contextPath}" baseinit="ajaxCheckLogin"></script>

</head>
<body>
<div class="body-warp">
    <div class="panel">
        <div class="panel-body">
		    <form id="saveform">
		    	<input type="hidden" id="userId" name="userId" value="${(obj.id)!}" />
		        <table class="form-table">
			        <tr>
		                <td><label class="form-label">角色分组</label></td>
		                <td>
		                	<select class="form-select" id="role" onchange="_change();">
		                        <option value="">--请选择--</option>
		                        <#list role_list as r>
		                        	<option value="${r.role}" <#if r.disabled==1>disabled="disabled"</#if> <#if r.role==obj.role>selected="selected"</#if>>${r.name}</option>
		                        </#list>
		                    </select>
		                </td>
		            </tr>
		            <tr id="depttr" <#if !obj??||obj.role!=5> style="display:none;" </#if> >
		            	<td><label class="form-label">管理学区</label></td>
		            	<td>
		            		<select class="form-select" id="control_deptId">
		            			<option value="">--请选择--</option>
		            			<#list deptList as dept>
		            				<option value="${dept.id}" <#if obj??&&obj.control_deptId==dept.id>selected="selected"</#if> >${dept.name}</option>
		            			</#list>
		            		</select>
		            	</td>
		            </tr>
		            <tr>
		                <td><label class="form-label">&nbsp;</label></td>
		                <td>
		                    <input class="btn btn-success btn-large" type="button" onclick="_save()" value="提交">
		                    <input class="btn btn-danger btn-large return-btn" type="button" onclick="_back()" value="关闭">
		                </td>
		            </tr>
		        </table>
		    </form>
        </div>
    </div>
</div>
<script type="text/javascript">
var prefix = "${contextPath}";

function _save() {
	var post = {};
	post.id = $("#userId").val();
	post.role = $("#role").val();
	post.control_deptId = $("#control_deptId").val();
	var url = "${contextPath}/user/modifyrole.ajax";
	if(!confirm("确定要修改分组信息吗？"))return false;
	$.post(url,post,function(data){
		if(1==data.s){
			alert(data.d||"操作成功！");
			parent.grid.refresh();
			parent.layer.closeAll();
		}else{
			alert(data.d||"操作失败！");
		}
	},"json");
}

function _change(){
	var role = $("#role").val();
	if(role == 5){
		$("#depttr").removeAttr("style");
	}else{
		$("#depttr").attr("style","display:none;");
	}
}

function _back() {
	parent.layer.closeAll();
}
$(document).ready(function(){
	
});
</script>
</body>
</html>